﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace tpsmi1002
{
    public partial class frmRechercheAction : Form
    {
        private frmAjoutTransaction formAjoutTransaction;
        private frmModificationTransactioncs formModificationTransaction;

        public frmRechercheAction(frmAjoutTransaction _frm)
        {
            InitializeComponent();
            this.formAjoutTransaction = _frm;
        }

        public frmRechercheAction(frmModificationTransactioncs _frm)
        {
            InitializeComponent();
            this.formModificationTransaction = _frm;
        }

        private void frmRechercheAction_Load(object sender, EventArgs e)
        {
            loadListViewStockData();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            setSelectedListViewItem();
            this.Hide();
        }

        private void lvStockData_DoubleClick(object sender, EventArgs e)
        {
            setSelectedListViewItem();
            this.Hide();
        }

        private void loadListViewStockData()
        {
            Controller.loadListStock(lvStockData);
        }

        private void setSelectedListViewItem()
        {
            if (lvStockData.SelectedItems.Count == 1)
            {
                formAjoutTransaction.setSelectedStock((Stock)lvStockData.SelectedItems[0].Tag);
            }
        }
    }
}
